/***************************************************************************
 创建者：华磊
 开始时间：         : 2020.11.16
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   程序指令视窗——常用窗口
*                                                                         *
 ***************************************************************************/
#include "instructionmenu.h"
#include "ui_instructionmenu.h"
#include "buttonfunctionmap.h"
#include <QDebug>

InstructionMenu::InstructionMenu( ButtonFunctionMap *funcMapIn, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::InstructionMenu)
{
    ui->setupUi(this);
    funcMap=funcMapIn;

    initialButtonText();
//    ui->nextPage_Btn->hide();
    //屏蔽机械手常用运动指令
//    ui->arcCom_Btn->hide();
//    ui->jCom_Btn->hide();
//    ui->lCom_Btn->hide();
//    ui->labelCom_Btn->setText("what");
//    ui->pushButton->setText("what222");
//    ui->pushButton_getInfo->setText("111");
//    qDebug()<<ui->pushButton->text();


}

InstructionMenu::~InstructionMenu()
{
    delete ui;
}

void InstructionMenu::changeLanguage()
{
    ui->retranslateUi(this);
    initialButtonText();
}

//void InstructionMenu::on_forwardPage_Btn_clicked()
//{
//    emit oftenForwardPage();
//}

void InstructionMenu::on_nextPage_Btn_clicked()
{
    emit oftenNextPage();
}

void InstructionMenu::on_jCom_Btn_clicked()
{
//    emit jInstruction();
    funcMap->emitSignalByButtonId(11);
}

void InstructionMenu::on_lCom_Btn_clicked()
{
//    emit lInstruction();
    funcMap->emitSignalByButtonId(12);
}

void InstructionMenu::on_arcCom_Btn_clicked()
{
//    emit arcInstruction();
    funcMap->emitSignalByButtonId(10);
}

void InstructionMenu::on_labelCom_Btn_clicked()
{
//    emit labelInstruction();
    funcMap->emitSignalByButtonId(1);
}

void InstructionMenu::on_jumpCom_Btn_clicked()
{
//    emit jumpInstruction();
    funcMap->emitSignalByButtonId(2);
}

void InstructionMenu::on_conditionCom_Btn_clicked()
{
//    emit conditionInstruction();
    funcMap->emitSignalByButtonId(4);
}

void InstructionMenu::on_waitCom_Btn_clicked()
{
//    emit waitInstruction();
    funcMap->emitSignalByButtonId(3);
}

void InstructionMenu::on_num_IO_Btn_clicked()
{
//    emit numberInstruction();
    funcMap->emitSignalByButtonId(5);
}

void InstructionMenu::on_analog_IO_Btn_clicked()
{
//    emit analogInstruction();
    funcMap->emitSignalByButtonId(6);
}

void InstructionMenu::on_moveMagCom_Btn_clicked()
{
//    emit moveMagInstruction();
    funcMap->emitSignalByButtonId(8);
}

void InstructionMenu::on_moveMagCom_Btn_2_clicked()
{
//    emit moveFreeInstruction();
    funcMap->emitSignalByButtonId(7);
}

void InstructionMenu::on_resetOdometry_Btn_clicked()
{
//    emit setOdometryInstruction();
    funcMap->emitSignalByButtonId(9);
}

void InstructionMenu::initialButtonText()
{


    for(int i=1;i<13;i++)
    {
        QString tmpText=funcMap->getFunctionTextByButtonId(i);
        switch(i)
        {
        case 1:
            if(tmpText.size()>0)
            {
                ui->labelCom_Btn->setText(tmpText);
            }
            else
            {
                ui->labelCom_Btn->hide();
            }

        break;
        case 2:
            if(tmpText.size()>0)
            {
                ui->jumpCom_Btn->setText(tmpText);
            }
            else
            {
                ui->jumpCom_Btn->hide();
            }
        break;
        case 3:
            if(tmpText.size()>0)
            {
                ui->waitCom_Btn->setText(tmpText);
            }
            else
            {
                ui->waitCom_Btn->hide();
            }

        break;
        case 4:
            if(tmpText.size()>0)
            {
                ui->conditionCom_Btn->setText(tmpText);
            }
            else
            {
                ui->conditionCom_Btn->hide();
            }

        break;
        case 5:
            if(tmpText.size()>0)
            {
                ui->num_IO_Btn->setText(tmpText);
            }
            else
            {
                ui->num_IO_Btn->hide();
            }

        break;
        case 6:
            if(tmpText.size()>0)
            {
                ui->analog_IO_Btn->setText(tmpText);
            }
            else
            {
                ui->analog_IO_Btn->hide();
            }

        break;
        case 7:
            if(tmpText.size()>0)
            {
                ui->moveMagCom_Btn_2->setText(tmpText);
            }
            else
            {
                ui->moveMagCom_Btn_2->hide();
            }

        break;
        case 8:
            if(tmpText.size()>0)
            {
                ui->moveMagCom_Btn->setText(tmpText);
            }
            else
            {
                ui->moveMagCom_Btn->hide();
            }


        break;
        case 9:
            if(tmpText.size()>0)
            {
                ui->resetOdometry_Btn->setText(tmpText);
            }
            else
            {
                ui->resetOdometry_Btn->hide();
            }

        break;
        case 10:
            if(tmpText.size()>0)
            {
                ui->arcCom_Btn->setText(tmpText);
            }
            else
            {
                ui->arcCom_Btn->hide();
            }

        break;
        case 11:
            if(tmpText.size()>0)
            {
                ui->jCom_Btn->setText(tmpText);
            }
            else
            {
                ui->jCom_Btn->hide();
            }

        break;
        case 12:
            if(tmpText.size()>0)
            {
                ui->lCom_Btn->setText(tmpText);
            }
            else
            {
                ui->lCom_Btn->hide();
            }

        break;
        }
    }
}
